import Vue from 'vue';
import App from './App.vue';
import router from '@/router';
import '@/css/global.css';
import '@/assets/fonts/iconfont.css';
import '@/plugins/element';
import axios from 'axios';
import VueQillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import TreeTable from 'vue-table-with-tree-grid'

axios.defaults.baseURL = `http://42.192.71.221:8889/api/private/v1/`;
// axios.defaults.baseURL = `https://www.liulongbin.top:8888/api/private/v1/`;
// axios.defaults.baseURL = `http://127.0.0.1:8888/api/private/v1/`;

// 请求axios拦截器  保证获取数据的权限设置
axios.interceptors.request.use((config) => {
	// console.log(config);
	// 通过回调函数为请求头添加验证信息
	config.headers.Authorization = window.sessionStorage.getItem('token');
	return config;
});

Vue.prototype.$http = axios;

Vue.component('tree-table', TreeTable)

// 时间戳单位是毫秒  为13位  否则是秒要乘1000
// 定义全局时间过滤器  任意组件调用
Vue.filter('dateFormat', function (originVal) {
	const dt = new Date(originVal * 1000)

	const y = dt.getFullYear()
	const m = (dt.getMonth() + 1 + '').padStart(2, '0')
	const d = (dt.getDate() + '').padStart(2, '0')

	const hh = (dt.getHours() + '').padStart(2, '0')
	const mm = (dt.getMinutes() + '').padStart(2, '0')
	const dd = (dt.getSeconds() + '').padStart(2, '0')

	return `${y}-${m}-${d} ${hh}:${mm}:${dd}`
})

Vue.use(VueQillEditor)

Vue.config.productionTip = false;

new Vue({
	router,
	render: (h) => h(App)
}).$mount('#app');
